3 * Cologne Blue: A nicer-looking alternative to Standard.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 if( !defined( 'MEDIAWIKI' ) ) {
33 class SkinCologneBlue
extends SkinTemplate
{
34 var $skinname = 'cologneblue', $stylename = 'cologneblue',
35 $template = 'CologneBlueTemplate';
36 var $useHeadElement = true;
39 * @param $out OutputPage
41 function setupSkinUserCss( OutputPage
$out ){
42 $out->addModuleStyles( 'mediawiki.legacy.shared' );
43 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
44 $out->addModuleStyles( 'skins.cologneblue' );
49 class CologneBlueTemplate
extends BaseTemplate
{
51 $this->html( 'headelement' );
52 echo $this->beforeContent();
53 $this->html( 'bodytext' );
55 echo $this->afterContent();
56 $this->html( 'dataAfterContent' );
58 echo "\n</body></html>";
63 * Language/charset variant links for classic-style skins
66 function variantLinks() {
69 /* show links to different language variants */
70 global $wgDisableLangConversion;
72 $title = $this->getSkin()->getTitle();
73 $lang = $title->getPageLanguage();
74 $variants = $lang->getVariants();
76 if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
77 && !$title->isSpecialPage() ) {
78 foreach ( $variants as $code ) {
79 $varname = $lang->getVariantname( $code );
81 if ( $varname == 'disable' ) {
84 $s = $this->getSkin()->getLanguage()->pipeList( array(
86 '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code . '">' . htmlspecialchars( $varname ) . '</a>'
94 function otherLanguages() {
95 global $wgHideInterlanguageLinks;
97 if ( $wgHideInterlanguageLinks ) {
101 $a = $this->getSkin()->getOutput()->getLanguageLinks();
103 if ( 0 == count( $a ) ) {
107 $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
110 if ( $this->getSkin()->getLanguage()->isRTL() ) {
111 $s .= '<span dir="ltr">';
114 foreach ( $a as $l ) {
116 $s .= wfMessage( 'pipe-separator' )->escaped();
121 $nt = Title
::newFromText( $l );
122 $text = Language
::fetchLanguageName( $nt->getInterwiki() );
124 $s .= Html
::element( 'a',
125 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
126 $text == '' ?
$l : $text );
129 if ( $this->getSkin()->getLanguage()->isRTL() ) {
137 function pageTitleLinks() {
139 $footlinks = $this->getFooterLinks();
141 foreach ( $footlinks['places'] as $item ) {
142 $s[] = $this->data
[$item];
145 return $this->getSkin()->getLanguage()->pipeList( $s );
148 function bottomLinks() {
149 $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
152 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
153 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
155 if ( $this->getSkin()->getUser()->isLoggedIn() ) {
156 $element[] = $this->watchThisPage();
159 $element[] = $this->talkLink();
160 $element[] = $this->historyLink();
161 $element[] = $this->whatLinksHere();
162 $element[] = $this->watchPageLinksLink();
164 $title = $this->getSkin()->getTitle();
167 $title->getNamespace() == NS_USER ||
168 $title->getNamespace() == NS_USER_TALK
170 $id = User
::idFromName( $title->getText() );
171 $ip = User
::isIP( $title->getText() );
173 # Both anons and non-anons have contributions list
175 $element[] = $this->userContribsLink();
178 if ( $this->getSkin()->showEmailUser( $id ) ) {
179 $element[] = $this->emailUserLink();
183 $s = implode( $element, $sep );
185 if ( $title->getArticleID() ) {
188 // Delete/protect/move links for privileged users
189 if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
190 $s .= $this->deleteThisPage();
193 if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
194 $s .= $sep . $this->protectThisPage();
197 if ( $this->getSkin()->getUser()->isAllowed( 'move' ) ) {
198 $s .= $sep . $this->moveThisPage();
202 $s .= "<br />\n" . $this->otherLanguages();
208 function editThisPage() {
209 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
210 $s = wfMessage( 'protectedpage' )->text();
212 $title = $this->getSkin()->getTitle();
213 if ( $title->quickUserCan( 'edit' ) && $title->exists() ) {
214 $t = wfMessage( 'editthispage' )->text();
215 } elseif ( $title->quickUserCan( 'create' ) && !$title->exists() ) {
216 $t = wfMessage( 'create-this-page' )->text();
218 $t = wfMessage( 'viewsource' )->text();
221 $s = Linker
::linkKnown(
225 $this->getSkin()->editUrlOptions()
232 function deleteThisPage() {
233 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
234 $title = $this->getSkin()->getTitle();
236 if ( $title->getArticleID() && ( !$diff ) && $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
237 $t = wfMessage( 'deletethispage' )->text();
239 $s = Linker
::linkKnown(
243 array( 'action' => 'delete' )
252 function protectThisPage() {
253 $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
254 $title = $this->getSkin()->getTitle();
256 if ( $title->getArticleID() && ( ! $diff ) && $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
257 if ( $title->isProtected() ) {
258 $text = wfMessage( 'unprotectthispage' )->text();
259 $query = array( 'action' => 'unprotect' );
261 $text = wfMessage( 'protectthispage' )->text();
262 $query = array( 'action' => 'protect' );
265 $s = Linker
::linkKnown(
278 function watchThisPage() {
280 $title = $this->getSkin()->getTitle();
282 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
283 if ( $this->getSkin()->getUser()->isWatched( $title ) ) {
284 $text = wfMessage( 'unwatchthispage' )->text();
286 'action' => 'unwatch',
287 'token' => UnwatchAction
::getUnwatchToken( $title, $this->getSkin()->getUser() ),
289 $id = 'mw-unwatch-link';
291 $text = wfMessage( 'watchthispage' )->text();
294 'token' => WatchAction
::getWatchToken( $title, $this->getSkin()->getUser() ),
296 $id = 'mw-watch-link';
299 $s = Linker
::linkKnown(
302 array( 'id' => $id ),
306 $s = wfMessage( 'notanarticle' )->text();
312 function moveThisPage() {
313 if ( $this->getSkin()->getTitle()->quickUserCan( 'move' ) ) {
314 return Linker
::linkKnown(
315 SpecialPage
::getTitleFor( 'Movepage' ),
316 wfMessage( 'movethispage' )->text(),
318 array( 'target' => $this->getSkin()->getTitle()->getPrefixedDBkey() )
321 // no message if page is protected - would be redundant
326 function historyLink() {
328 $this->getSkin()->getTitle(),
329 wfMessage( 'history' )->escaped(),
330 array( 'rel' => 'archives' ),
331 array( 'action' => 'history' )
335 function whatLinksHere() {
336 return Linker
::linkKnown(
337 SpecialPage
::getTitleFor( 'Whatlinkshere', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
338 wfMessage( 'whatlinkshere' )->escaped()
342 function userContribsLink() {
343 return Linker
::linkKnown(
344 SpecialPage
::getTitleFor( 'Contributions', $this->getSkin()->getTitle()->getDBkey() ),
345 wfMessage( 'contributions' )->escaped()
349 function emailUserLink() {
350 return Linker
::linkKnown(
351 SpecialPage
::getTitleFor( 'Emailuser', $this->getSkin()->getTitle()->getDBkey() ),
352 wfMessage( 'emailuser' )->escaped()
356 function watchPageLinksLink() {
357 if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
358 return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
360 return Linker
::linkKnown(
361 SpecialPage
::getTitleFor( 'Recentchangeslinked', $this->getSkin()->getTitle()->getPrefixedDBkey() ),
362 wfMessage( 'recentchangeslinked-toolbox' )->escaped()
367 function talkLink() {
368 $title = $this->getSkin()->getTitle();
369 if ( NS_SPECIAL
== $title->getNamespace() ) {
370 # No discussion links for special pages
374 $linkOptions = array();
376 if ( $title->isTalkPage() ) {
377 $link = $title->getSubjectPage();
378 switch( $link->getNamespace() ) {
380 $text = wfMessage( 'articlepage' );
383 $text = wfMessage( 'userpage' );
386 $text = wfMessage( 'projectpage' );
389 $text = wfMessage( 'imagepage' );
390 # Make link known if image exists, even if the desc. page doesn't.
391 if ( wfFindFile( $link ) )
392 $linkOptions[] = 'known';
395 $text = wfMessage( 'mediawikipage' );
398 $text = wfMessage( 'templatepage' );
401 $text = wfMessage( 'viewhelppage' );
404 $text = wfMessage( 'categorypage' );
407 $text = wfMessage( 'articlepage' );
410 $link = $title->getTalkPage();
411 $text = wfMessage( 'talkpage' );
414 $s = Linker
::link( $link, $text->text(), array(), array(), $linkOptions );
424 function beforeContent() {
430 <a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
431 <?php
echo wfMessage( 'sitetitle' )->escaped() ?
>
434 <p id
="sitesub"><?php
echo wfMessage( 'sitesubtitle' )->escaped() ?
></p
>
437 <p id
="syslinks"><?php
echo $this->sysLinks() ?
></p
>
438 <p id
="variantlinks"><?php
echo $this->variantLinks() ?
></p
>
440 <div id
="linkcollection">
441 <div id
="langlinks"><?php
echo str_replace( '<br />', '', $this->otherLanguages() ) ?
></div
>
442 <?php
echo $this->getSkin()->getCategories() ?
>
443 <div id
="titlelinks"><?php
echo $this->pageTitleLinks() ?
></div
>
444 <?php
if ( $this->data
['newtalk'] ) { ?
>
445 <div
class="usermessage"><strong
><?php
echo $this->data
['newtalk'] ?
></strong
></div
>
450 <?php
if ( $this->getSkin()->getSiteNotice() ) { ?
>
451 <div id
="siteNotice"><?php
echo $this->getSkin()->getSiteNotice() ?
></div
>
453 <h1 id
="firstHeading"><span dir
="auto"><?php
echo $this->data
['title'] ?
></span
></h1
>
454 <?php
if ( $this->translator
->translate( 'tagline' ) ) { ?
>
455 <p
class="tagline"><?php
echo htmlspecialchars( $this->translator
->translate( 'tagline' ) ) ?
></p
>
457 <?php
if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?
>
458 <p
class="subtitle"><?php
echo $this->getSkin()->getOutput()->getSubtitle() ?
></p
>
460 <?php
if ( $this->getSkin()->subPageSubtitle() ) { ?
>
461 <p
class="subpages"><?php
echo $this->getSkin()->subPageSubtitle() ?
></p
>
464 $s = ob_get_contents();
475 function afterContent() {
481 // Page-related links
482 echo $this->bottomLinks();
485 // Footer and second searchbox
486 echo $this->getSkin()->getLanguage()->pipeList( array(
487 $this->getSkin()->mainPageLink(),
488 $this->getSkin()->aboutLink(),
489 $this->searchForm( 'footer' )
493 // Standard footer info
494 $footlinks = $this->getFooterLinks();
495 if ( $footlinks['info'] ) {
496 foreach ( $footlinks['info'] as $item ) {
497 echo $this->data
[$item] . ' ';
503 <?php
echo $this->quickBar() ?
>
505 $s = ob_get_contents();
516 function sysLinks() {
518 $this->getSkin()->mainPageLink(),
520 Title
::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
521 wfMessage( 'about' )->text()
524 Title
::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
525 wfMessage( 'help' )->text()
528 Title
::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
529 wfMessage( 'faq' )->text()
533 $personalUrls = $this->getPersonalTools();
534 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
535 if ( $personalUrls[$key] ) {
536 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
540 return $this->getSkin()->getLanguage()->pipeList( $s );
547 * @param $heading string
552 function menuHead( $heading ) {
553 return "\n<h6>" . htmlspecialchars( $heading ) . "</h6>";
557 * Compute the sidebar
565 $s = "\n<div id='quickbar'>";
569 $plain_bar = $this->data
['sidebar'];
572 // Massage the sidebar
573 // We want to place SEARCH at the beginning and a lot of stuff before TOOLBOX (or at the end, if it's missing)
574 $additions_done = false;
575 while ( !$additions_done ) {
576 $bar = array(); // Empty it out
578 // Always display search on top
579 $bar['SEARCH'] = true;
581 foreach ( $plain_bar as $heading => $links ) {
582 if ( $heading == 'TOOLBOX' ) {
583 if( $links !== NULL ) {
584 // If this is not a toolbox prosthetic we inserted outselves, fill it out
585 $plain_bar['TOOLBOX'] = $this->getToolbox();
588 // And insert the stuff
590 // "This page" and "Edit" menus
591 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
592 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
593 // We also don't use $...['variants'], these are displayed in the top menu.
594 $content_navigation = $this->data
['content_navigation'];
595 $qbpageoptions = array_merge(
596 $content_navigation['namespaces'],
598 'history' => $content_navigation['views']['history'],
599 'watch' => $content_navigation['actions']['watch'],
600 'unwatch' => $content_navigation['actions']['unwatch'],
603 $content_navigation['actions']['watch'] = null;
604 $content_navigation['actions']['unwatch'] = null;
605 $qbedit = array_merge(
607 'edit' => $content_navigation['views']['edit'],
608 'addsection' => $content_navigation['views']['addsection'],
610 $content_navigation['actions']
612 $bar['qbedit'] = $qbedit;
613 $bar['qbpageoptions'] = $qbpageoptions;
615 // Personal tools ("My pages")
616 $bar['qbmyoptions'] = $this->getPersonalTools();
617 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
618 $bar['qbmyoptions'][$key] = false;
621 $additions_done = true;
624 // Re-insert current heading, unless it's SEARCH
625 if ( $heading != 'SEARCH' ) {
626 $bar[$heading] = $plain_bar[$heading];
630 // If TOOLBOX is missing, $additions_done is still false
631 if ( !$additions_done ) {
632 $plain_bar['TOOLBOX'] = false;
636 foreach ( $bar as $heading => $links ) {
637 if ( $heading == 'SEARCH' ) {
638 $s .= $this->menuHead( wfMessage( 'qbfind' )->text() );
639 $s .= $this->searchForm( 'sidebar' );
640 } elseif ( $heading == 'LANGUAGES' ) {
641 // discard these; we display languages below page content
644 // Use the navigation heading from standard sidebar as the "browse" section
645 if ( $heading == 'navigation' ) {
646 $heading = 'qbbrowse';
648 if ( $heading == 'TOOLBOX' ) {
649 $heading = 'toolbox';
652 $headingMsg = wfMessage( $heading );
654 $t = $this->menuHead( $headingMsg->exists() ?
$headingMsg->text() : $heading );
656 foreach ( $links as $key => $link ) {
657 // Can be empty due to rampant sidebar massaging we're doing above
660 $t .= $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ) . $sep;
671 $s .= $sep . "\n</div>\n";
676 * @param $label string
681 function searchForm( $which ) {
682 global $wgUseTwoButtonsSearchForm;
684 $search = $this->getSkin()->getRequest()->getText( 'search' );
685 $action = $this->data
['searchaction'];
686 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
687 if( $which == 'footer' ) {
688 $s .= wfMessage( 'qbfind' )->text() . ": ";
691 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
692 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
693 . ($which == 'footer' ?
" " : "<br />")
694 . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
696 if( $wgUseTwoButtonsSearchForm ) {
697 $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
699 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";